﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Maticsoft.DBUtility;
using EnvironmentManagerSystem.MODE;
using MySql.Data.MySqlClient;
using System.Collections;
using System.Web;

namespace EnvironmentManagerSystem.BLL
{
    public class NoticeService
    {
        /// <summary>
        /// 获得结束通知SQL
        /// </summary>
        /// <returns></returns>
        public static string EndNotice()
        {
            return string.Format(@"update tbs001_notice set enddate='{0}' where project_id =
                      (SELECT ID FROM tbs001_developprojectbasicinfo WHERE ProjectName='{1}') and enddate is null",
                      DateTime.Now.ToString("yyyy-MM-dd"), HttpContext.Current.Session["pjName"].ToString());
        }

        /// <summary>
        /// 项目通知总耗费天数
        /// </summary>
        /// <param name="StepDate">某一步骤确认日期</param>
        /// <param name="AcceptanceDate">受理日期</param>
        /// <returns></returns>
        public static int ProNoticeDays(string StepDate, string AcceptanceDate)
        {
            string strSql = string.Format(@"SELECT MIN(DATE) as startdate,enddate FROM tbs001_notice WHERE project_id=
                                 (SELECT ID FROM tbs001_developprojectbasicinfo WHERE ProjectName='{0}') AND enddate<='{1}' AND DATE>='{2}' 
                                 GROUP BY enddate", HttpContext.Current.Session["pjName"].ToString(), StepDate, AcceptanceDate);
            DataTable dt = DbHelperMySQL.Query(strSql).Tables[0];
            int NoticeDays = 0;
            foreach (DataRow dr in dt.Rows)
            {
                NoticeDays += (Convert.ToDateTime(dr[1]) - Convert.ToDateTime(dr[0])).Days;
            }
            return NoticeDays;
        }

        #region 添加项目通知信息表(项目名称,内容,时间,发布人,状态)
        public static bool AddNotice(NoticeModels nm)
        {
            try
            {
                List<string> list = new List<string>();
                string strSql = string.Format("INSERT INTO tbs001_notice(project_id,content,date,publisher,status) VALUES ({0},'{1}','{2}','{3}',{4})", nm.project_id, nm.content, nm.date, nm.publisher, nm.status);
                list.Add(strSql);
                strSql = string.Format("update tbs001_developprojectbasicinfo set noticestate=1 where ProjectName ='{0}'", HttpContext.Current.Session["pjName"].ToString());
                list.Add(strSql);
                return DbHelperMySQL.ExecuteSqlTran(list) > 0 ? true : false;
            }
            catch
            {
                return false;
            }
        }
        #endregion
        /// <summary>
        /// 查询项目通知
        /// </summary>
        /// <returns></returns>
        public static DataTable GetNotices()
        {
            try
            {
                string strSql = string.Format("SELECT a.* FROM tbs001_notice a,tbs001_developprojectbasicinfo b WHERE a.project_id=b.ID AND b.ProjectName ='{0}' order by a.id", HttpContext.Current.Session["pjName"].ToString());
                return DbHelperMySQL.Query(strSql).Tables[0];
            }
            catch
            { return null; }
        }

        /// <summary>
        /// 修改项目通知的状态
        /// </summary>
        /// <param name="State"></param>
        /// <returns></returns>
        public static bool UpdateNoticeState(int State)
        {
            try
            {
                string strSql = string.Format("Update tbs001_developprojectbasicinfo set noticestate={0} where ProjectName ='{1}'", State, HttpContext.Current.Session["pjName"].ToString());
                return DbHelperMySQL.ExecuteSql(strSql) > 0 ? true : false;
            }
            catch
            { return false; }
        }
        #region 查询所有
        public static DataTable GetSelectAll()
        {
            try
            {
                StringBuilder brb = new StringBuilder();
                //brb.AppendFormat("SELECT tbs001_developprojectbasicinfo.*, tbs001_constructionunit.ID, tbs001_constructionunit.NAME AS AClassName, tbs001_evaluationunit.UnitName AS dd FROM tbs001_developprojectbasicinfo,tbs001_constructionunit,tbs001_evaluationunit WHERE tbs001_developprojectbasicinfo.js = tbs001_constructionunit.ID AND tbs001_developprojectbasicinfo.hp = tbs001_evaluationunit.ID");
                brb.AppendFormat("SELECT tbs001_developprojectbasicinfo.*, tbs001_constructionunit.ID, tbs001_constructionunit.NAME AS AClassName, tbs001_evaluationunit.UnitName AS dd FROM tbs001_developprojectbasicinfo,tbs001_constructionunit,tbs001_evaluationunit WHERE tbs001_developprojectbasicinfo.js = tbs001_constructionunit.ID AND tbs001_developprojectbasicinfo.hp = tbs001_evaluationunit.ID AND tbs001_developprojectbasicinfo.shoulituihuishanchu != 2");
                return DbHelperMySQL.Query(brb.ToString()).Tables[0];
            }
            catch { return null; }
        }
        //根据ID查询
        public static DataTable GetSelectID(string ID)
        {
            try
            {
                StringBuilder brb = new StringBuilder();
                brb.AppendFormat("SELECT tbs001_developprojectbasicinfo.*, tbs001_constructionunit.ID, tbs001_constructionunit.NAME AS AClassName, tbs001_evaluationunit.UnitName AS dd FROM tbs001_developprojectbasicinfo,tbs001_constructionunit,tbs001_evaluationunit WHERE tbs001_developprojectbasicinfo.js = tbs001_constructionunit.ID AND tbs001_developprojectbasicinfo.hp = tbs001_evaluationunit.ID AND tbs001_developprojectbasicinfo.shoulituihuishanchu != 2 and tbs001_developprojectbasicinfo.ID='"+ID+"'");
                return DbHelperMySQL.Query(brb.ToString()).Tables[0];
            }
            catch { return null; }
        }
        //查询上报项目
        public static DataTable GetSelectAllShangBao()
        {
            try
            {
                StringBuilder brb = new StringBuilder();
                brb.AppendFormat("SELECT tbs001_developprojectbasicinfo.*, tbs001_constructionunit.ID, tbs001_constructionunit.NAME AS AClassName, tbs001_evaluationunit.UnitName AS dd FROM tbs001_developprojectbasicinfo,tbs001_constructionunit,tbs001_evaluationunit WHERE tbs001_developprojectbasicinfo.js = tbs001_constructionunit.ID AND tbs001_developprojectbasicinfo.hp = tbs001_evaluationunit.ID AND tbs001_developprojectbasicinfo.ReportingTrace IS NOT NULL AND tbs001_developprojectbasicinfo.reportstate IS NOT NULL");
                return DbHelperMySQL.Query(brb.ToString()).Tables[0];
            }
            catch { return null; }
        }

        #endregion
        #region 查询评价单位
        public static DataTable GetSelectAllP(string id)
        {
            try
            {
                StringBuilder brb = new StringBuilder();
                brb.AppendFormat("SELECT tbs001_developprojectbasicinfo.*,tbs001_constructionunit.ID,tbs001_constructionunit.NAME AS AClassName,tbs001_evaluationunit.UnitName AS dd,tbs001_evaluationunit.ID AS id,tbs001_projectleader.UnitID,tbs001_projectleader.NAME AS pjname FROM tbs001_developprojectbasicinfo,tbs001_constructionunit,tbs001_evaluationunit ,tbs001_projectleader WHERE tbs001_developprojectbasicinfo.js = tbs001_constructionunit.ID  AND tbs001_developprojectbasicinfo.hp = tbs001_evaluationunit.ID AND tbs001_projectleader.UnitID= tbs001_evaluationunit.ID AND tbs001_evaluationunit.ID =" + id + " GROUP BY tbs001_developprojectbasicinfo.ProjectName");
                return DbHelperMySQL.Query(brb.ToString()).Tables[0];
            }
            catch { return null; }
        }

        #endregion

        #region 搜索条件上报(按项目名称,环境单位,上报状态)
        public static DataTable GetSelectss(string ProjectName, string hp, string reportstate)
        {
            try
            {
                string strPJ = "";
                if (ProjectName == "")//项目名称
                {
                }
                else
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.ProjectName like '%" + ProjectName + "%'";
                }
                if (hp == "请选择")//评价单位
                {
                }
                else if (hp == "全部")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.hp IS NOT NULL";
                }
                else
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.hp like '%" + hp + "%'";
                }
                if (reportstate == "请选择")//上报状态
                {
                }
                else if (reportstate == "全部")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.reportstate IS NOT NULL";
                }
                else if (reportstate == "已上报")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.reportstate =3";
                }
                else if (reportstate == "未上报")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.reportstate =1";
                }
                else if (reportstate == "退回")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.reportstate =2";
                }
                StringBuilder brb = new StringBuilder();
                brb.AppendFormat("SELECT tbs001_developprojectbasicinfo.*, tbs001_constructionunit.ID, tbs001_constructionunit.NAME AS AClassName, tbs001_evaluationunit.UnitName AS dd FROM tbs001_developprojectbasicinfo,tbs001_constructionunit,tbs001_evaluationunit WHERE tbs001_developprojectbasicinfo.js = tbs001_constructionunit.ID AND tbs001_developprojectbasicinfo.hp = tbs001_evaluationunit.ID AND tbs001_developprojectbasicinfo.ReportingTrace IS NOT NULL AND tbs001_developprojectbasicinfo.reportstate IS NOT NULL AND 1=1 " + strPJ + " ");
                return DbHelperMySQL.Query(brb.ToString()).Tables[0];
            }
            catch { return null; }
        }
        #endregion

        #region 搜索条件(按项目名称，项目组织人,)
        public static DataTable GetSelect(string ProjectName, string pingshenxiangmufuzeren)
        {
            try
            {
                string strPJ = "";
                if (ProjectName == "")//项目名称
                {
                }
                else
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.ProjectName like '%" + ProjectName + "%'";
                }
                if (pingshenxiangmufuzeren == "待定")//项目组织人
                {
                }
                else
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.pingshenxiangmufuzeren like '%" + pingshenxiangmufuzeren + "%'";
                }
                StringBuilder brb = new StringBuilder();
                brb.AppendFormat("SELECT tbs001_developprojectbasicinfo.*, tbs001_constructionunit.ID,tbs001_constructionunit.NAME AS AClassName, tbs001_evaluationunit.UnitName AS dd FROM tbs001_developprojectbasicinfo,tbs001_constructionunit ,tbs001_evaluationunit WHERE tbs001_developprojectbasicinfo.js=tbs001_constructionunit.ID AND tbs001_developprojectbasicinfo.hp=tbs001_evaluationunit.ID AND 1=1 " + strPJ + " ");
                return DbHelperMySQL.Query(brb.ToString()).Tables[0];
            }
            catch { return null; }
        }
        #endregion

        #region 搜索条件(按受理搜索开始时间，受理搜索结束时间，踏查搜索开始时间，踏查搜索结束时间,会议搜索开始时间，会议搜索结束时间,行业类别一，行业类别二，行业类别三，环评类别，项目名称，评价单位，流程，部门，项目组织人，城市，地区，项目状态记录,退回,绿色通道,会议复审,核定合同金额)
        public static DataTable GetSelectS(ref string QueryCondition, string XiangMuShouLiShiJianK, string XiangMuShouLiShiJianJ, string TaChaRiQiK, string TaChaRiQiJ, string HuiYiShiJianK, string HuiYiShiJianJ, string IndustryType1, string IndustryType2, string IndustryType3, string huanpingleibie, string ProjectName, string hp, string LiuCheng, string fenpeizhixingbumen, string pingshenxiangmufuzeren, string AddressCode0, string AddressCode1, string pingguyijianxiangmuzhuangtai, bool tuihuiqueren, bool lvsetongdao, bool queren, string hedinghetongjine, string ReceiveState, string ddlxiangmushoulishijian, string txtreportdateK, string txtreportdatej, bool cbReports, bool cbReportb, bool cbNoticeState)
        {
            try
            {
                string strPJ = "";
                if (XiangMuShouLiShiJianK != "" && XiangMuShouLiShiJianJ != "")//受理搜索开始时间，受理搜索结束时间
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.xiangmushoulishijian between '" + XiangMuShouLiShiJianK + "' and '" + XiangMuShouLiShiJianJ + "'";
                }
                if (TaChaRiQiK != "" && TaChaRiQiJ != "")//踏查搜索开始时间，踏查搜索结束时间
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.tachariqi between '" + TaChaRiQiK + "' and '" + TaChaRiQiJ + "'";
                }
                //if (HuiYiShiJianK != "" && HuiYiShiJianJ != "")//会议搜索开始时间，会议搜索结束时间
                //{
                //    strPJ += " AND tbs001_developprojectbasicinfo.huiyishijian between '" + HuiYiShiJianK + "' and '" + HuiYiShiJianJ + "'";
                //}
                if (HuiYiShiJianK != "" && HuiYiShiJianJ != "")//会议搜索开始时间，会议搜索结束时间
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.zhuanjiahuiyichuliriqi between '" + HuiYiShiJianK + "' and '" + HuiYiShiJianJ + "'";
                }

                if (IndustryType1 == "请选择")//行业类别一
                {
                }
                else if (IndustryType1 == "全部")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.IndustryType1 IS NOT NULL";
                }
                else
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.IndustryType1 = '" + IndustryType1 + "'";
                }
                if (IndustryType2 == "")//行业类别二
                {
                }
                else if (IndustryType2 == "请选择")
                {
                }
                else if (IndustryType2 == "全部")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.IndustryType2 IS NOT NULL";
                }
                else
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.IndustryType2 = '" + IndustryType2 + "'";
                }
                if (IndustryType3 == "")//行业类别三
                {
                }
                else if (IndustryType3 == "请选择")
                {
                }
                else if (IndustryType3 == "全部")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.IndustryType3 IS NOT NULL";
                }
                else
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.IndustryType3 = '" + IndustryType3 + "'";
                }
                if (huanpingleibie == "请选择")//环评类别
                {
                }
                else if (huanpingleibie == "全部")//环评类别
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.huanpingleibie IS NOT NULL";
                }
                else
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.huanpingleibie like '%" + huanpingleibie + "%'";
                }
                if (ProjectName == "")//项目名称
                {
                }
                else
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.ProjectName like '%" + ProjectName + "%'";
                }
                if (hp == "请选择")//评价单位
                {
                }
                else if (hp == "全部")//评价单位
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.hp IS NOT NULL";
                }
                else
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.hp like '%" + hp + "%'";
                }
                if (LiuCheng == "请选择")//流程
                {
                }
                if (LiuCheng == "全部")
                {
                    //受理，部门分配，项目负责，现场踏查，专家会议，评估意见，项目考察，汇总上报
                    strPJ += " AND tbs001_developprojectbasicinfo.shoulituihuishanchu=" + 1 + " and  tbs001_developprojectbasicinfo.fenpeiquerenren IS NOT NULL and  tbs001_developprojectbasicinfo.fuzetuihuiqueren=" + 1 + " and  tbs001_developprojectbasicinfo.tachaquerentuihui=" + 1 + " and  tbs001_developprojectbasicinfo.zhuanjiahuiyiquerenren IS NOT NULL and  tbs001_developprojectbasicinfo.pingguyijianchuliren IS NOT NULL and  tbs001_developprojectbasicinfo.xiangmukaopingchuliren IS NOT NULL and  tbs001_developprojectbasicinfo.reportstate=" + 1 + "";
                }
                if (LiuCheng == "受理")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.shoulituihuishanchu=" + 1 + "";
                }
                if (LiuCheng == "部门分配")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.fenpeiquerenren IS NOT NULL";
                }
                if (LiuCheng == "项目负责")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.fuzetuihuiqueren=" + 1 + "";
                }
                if (LiuCheng == "现场踏查")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.tachaquerentuihui=" + 1 + "";
                }
                if (LiuCheng == "专家会议")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.zhuanjiahuiyiquerenren IS NOT NULL";
                }
                if (LiuCheng == "评估意见")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.pingguyijianchuliren IS NOT NULL";
                }
                if (LiuCheng == "项目考察")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.xiangmukaopingchuliren IS NOT NULL";
                }
                if (LiuCheng == "汇总上报")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.reportstate=" + 1 + "";
                }
                if (fenpeizhixingbumen == "请选择")//部门
                {
                }
                else if (fenpeizhixingbumen == "全部")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.fenpeizhixingbumen IS NOT NULL";
                }
                else
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.fenpeizhixingbumen like '%" + fenpeizhixingbumen + "%'";
                }
                if (pingshenxiangmufuzeren == "请选择")//项目组织人
                {
                }
                else if (pingshenxiangmufuzeren == "全部")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.pingshenxiangmufuzeren IS NOT NULL";
                }
                else
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.pingshenxiangmufuzeren like '%" + pingshenxiangmufuzeren + "%'";
                }
                if (AddressCode0 == "请选择")//城市
                {

                }
                else
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.AddressCode1 like '%" + AddressCode0 + "%'";
                    //strPJ += " AND tbs001_developprojectbasicinfo.AddressCode like '%" + AddressCode0 + "%'";
                }
                if (AddressCode1 == "")//地区
                {
                }
                else if (AddressCode1 == "请选择")
                {
                }
                else
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.AddressCode1 like '" + AddressCode0 + "," + AddressCode1 + "'";
                }
                if (pingguyijianxiangmuzhuangtai == "请选择")//项目状态记录
                {
                }
                if (pingguyijianxiangmuzhuangtai == "全部")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.pingguyijianxiangmuzhuangtai = '1736,1737,2288'||tbs001_developprojectbasicinfo.pingguyijianxiangmuzhuangtai = '1737,1736,2288'";
                }
                if (pingguyijianxiangmuzhuangtai == "未批先建")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.pingguyijianxiangmuzhuangtai like '%1736%'";
                }
                if (pingguyijianxiangmuzhuangtai == "重要环境保护目标")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.pingguyijianxiangmuzhuangtai like '%1737%'";
                }
                if (pingguyijianxiangmuzhuangtai == "缺少规划环评")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.pingguyijianxiangmuzhuangtai like '%2288%'";
                }
                if (tuihuiqueren == true)//退回
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.shoulituihuishanchu=" + 2 + "";
                }
                if (lvsetongdao == true)//绿色通道
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.lvsetongdao=" + 1 + "";
                }
                if (queren == true)//复审会议确认
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.queren=" + 1 + "";
                }
                if (hedinghetongjine == "")//核定合同金额
                {
                }
                else
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.hedinghetongjine > " + hedinghetongjine + "";
                }
                if (ReceiveState == "请选择")//是否付款
                {
                }
                else if (ReceiveState == "全部")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.ReceiveState IS NOT NULL";
                }
                else if (ReceiveState == "已付款")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.ReceiveState=" + 1 + "";
                }
                else
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.ReceiveState=" + 0 + "";
                }
                if (ddlxiangmushoulishijian == "请选择")//是否付款
                {
                }
                else if (ddlxiangmushoulishijian == "2010")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.xiangmushoulishijian like '%" + ddlxiangmushoulishijian + "%'";
                }
                else if (ddlxiangmushoulishijian == "2011")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.xiangmushoulishijian like '%" + ddlxiangmushoulishijian + "%'";
                }
                else if (ddlxiangmushoulishijian == "2012")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.xiangmushoulishijian like '%" + ddlxiangmushoulishijian + "%'";
                }
                else if (ddlxiangmushoulishijian == "2013")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.xiangmushoulishijian like '%" + ddlxiangmushoulishijian + "%'";
                }
                else if (ddlxiangmushoulishijian == "2014")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.xiangmushoulishijian like '%" + ddlxiangmushoulishijian + "%'";
                }
                else if (ddlxiangmushoulishijian == "2015")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.xiangmushoulishijian like '%" + ddlxiangmushoulishijian + "%'";
                }
                else if (ddlxiangmushoulishijian == "2016")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.xiangmushoulishijian like '%" + ddlxiangmushoulishijian + "%'";
                }
                else if (ddlxiangmushoulishijian == "2017")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.xiangmushoulishijian like '%" + ddlxiangmushoulishijian + "%'";
                }
                else if (ddlxiangmushoulishijian == "2018")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.xiangmushoulishijian like '%" + ddlxiangmushoulishijian + "%'";
                }
                else if (ddlxiangmushoulishijian == "2019")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.xiangmushoulishijian like '%" + ddlxiangmushoulishijian + "%'";
                }
                if (txtreportdateK != "" && txtreportdatej != "")//汇总上报搜索开始时间，受理搜索结束时间
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.reportdate between '" + txtreportdateK + "' and '" + txtreportdatej + "'";
                }
                if (cbReports == true)//报告书
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.Report='报告书'";
                }
                if (cbReportb == true)//报告表
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.Report='报告表'";
                }
                if (cbNoticeState == true)//审核退回
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.NoticeState=" + 2 + "";
                }
                StringBuilder brb = new StringBuilder();
                brb.AppendFormat("SELECT tbs001_developprojectbasicinfo.*, tbs001_constructionunit.ID,tbs001_constructionunit.NAME AS AClassName, tbs001_evaluationunit.UnitName AS dd FROM tbs001_developprojectbasicinfo,tbs001_constructionunit ,tbs001_evaluationunit WHERE tbs001_developprojectbasicinfo.js=tbs001_constructionunit.ID AND tbs001_developprojectbasicinfo.hp=tbs001_evaluationunit.ID AND tbs001_developprojectbasicinfo.shoulituihuishanchu != 2 AND 1=1 " + strPJ + " ");
                QueryCondition = strPJ;
                return DbHelperMySQL.Query(brb.ToString()).Tables[0];
            }
            catch { return null; }
        }
        #endregion


        #region 搜索条件(按受理搜索开始时间，受理搜索结束时间，踏查搜索开始时间，踏查搜索结束时间,会议搜索开始时间，会议搜索结束时间,行业类别一，行业类别二，行业类别三，环评类别，项目名称，评价单位，流程，部门，项目组织人，城市，地区，项目状态记录,退回,绿色通道,会议复审,核定合同金额)
        public static DataTable GetSelectSsl(ref string QueryCondition, string XiangMuShouLiShiJianK, string XiangMuShouLiShiJianJ, string TaChaRiQiK, string TaChaRiQiJ, string HuiYiShiJianK, string HuiYiShiJianJ, string IndustryType1, string IndustryType2, string IndustryType3, string huanpingleibie, string ProjectName, string hp, string LiuCheng, string fenpeizhixingbumen, string pingshenxiangmufuzeren, string AddressCode0, string AddressCode1, string pingguyijianxiangmuzhuangtai, bool tuihuiqueren, bool lvsetongdao, bool queren, string hedinghetongjine, string ReceiveState, string ddlxiangmushoulishijian, string txtreportdateK, string txtreportdatej, bool cbReports, bool cbReportb, bool cbNoticeState)
        {
            try
            {
                string strPJ = "";
                if (XiangMuShouLiShiJianK != "" && XiangMuShouLiShiJianJ != "")//受理搜索开始时间，受理搜索结束时间
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.xiangmushoulishijian between '" + XiangMuShouLiShiJianK + "' and '" + XiangMuShouLiShiJianJ + "'";
                }
                if (TaChaRiQiK != "" && TaChaRiQiJ != "")//踏查搜索开始时间，踏查搜索结束时间
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.tachariqi between '" + TaChaRiQiK + "' and '" + TaChaRiQiJ + "'";
                }
                //if (HuiYiShiJianK != "" && HuiYiShiJianJ != "")//会议搜索开始时间，会议搜索结束时间
                //{
                //    strPJ += " AND tbs001_developprojectbasicinfo.huiyishijian between '" + HuiYiShiJianK + "' and '" + HuiYiShiJianJ + "'";
                //}
                if (HuiYiShiJianK != "" && HuiYiShiJianJ != "")//会议搜索开始时间，会议搜索结束时间
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.zhuanjiahuiyichuliriqi between '" + HuiYiShiJianK + "' and '" + HuiYiShiJianJ + "'";
                }

                if (IndustryType1 == "请选择")//行业类别一
                {
                }
                else if (IndustryType1 == "全部")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.IndustryType1 IS NOT NULL";
                }
                else
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.IndustryType1 = '" + IndustryType1 + "'";
                }
                if (IndustryType2 == "")//行业类别二
                {
                }
                else if (IndustryType2 == "请选择")
                {
                }
                else if (IndustryType2 == "全部")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.IndustryType2 IS NOT NULL";
                }
                else
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.IndustryType2 = '" + IndustryType2 + "'";
                }
                if (IndustryType3 == "")//行业类别三
                {
                }
                else if (IndustryType3 == "请选择")
                {
                }
                else if (IndustryType3 == "全部")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.IndustryType3 IS NOT NULL";
                }
                else
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.IndustryType3 = '" + IndustryType3 + "'";
                }
                if (huanpingleibie == "请选择")//环评类别
                {
                }
                else if (huanpingleibie == "全部")//环评类别
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.huanpingleibie IS NOT NULL";
                }
                else
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.huanpingleibie like '%" + huanpingleibie + "%'";
                }
                if (ProjectName == "")//项目名称
                {
                }
                else
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.ProjectName like '%" + ProjectName + "%'";
                }
                if (hp == "请选择")//评价单位
                {
                }
                else if (hp == "全部")//评价单位
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.hp IS NOT NULL";
                }
                else
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.hp like '%" + hp + "%'";
                }
                if (LiuCheng == "请选择")//流程
                {
                }
                if (LiuCheng == "全部")
                {
                    //受理，部门分配，项目负责，现场踏查，专家会议，评估意见，项目考察，汇总上报
                    strPJ += " AND tbs001_developprojectbasicinfo.shoulituihuishanchu=" + 1 + " and  tbs001_developprojectbasicinfo.fenpeiquerenren IS NOT NULL and  tbs001_developprojectbasicinfo.fuzetuihuiqueren=" + 1 + " and  tbs001_developprojectbasicinfo.tachaquerentuihui=" + 1 + " and  tbs001_developprojectbasicinfo.zhuanjiahuiyiquerenren IS NOT NULL and  tbs001_developprojectbasicinfo.pingguyijianchuliren IS NOT NULL and  tbs001_developprojectbasicinfo.xiangmukaopingchuliren IS NOT NULL and  tbs001_developprojectbasicinfo.reportstate=" + 1 + "";
                }
                if (LiuCheng == "受理")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.shoulituihuishanchu=" + 1 + "";
                }
                if (LiuCheng == "部门分配")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.fenpeiquerenren IS NOT NULL";
                }
                if (LiuCheng == "项目负责")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.fuzetuihuiqueren=" + 1 + "";
                }
                if (LiuCheng == "现场踏查")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.tachaquerentuihui=" + 1 + "";
                }
                if (LiuCheng == "专家会议")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.zhuanjiahuiyiquerenren IS NOT NULL";
                }
                if (LiuCheng == "评估意见")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.pingguyijianchuliren IS NOT NULL";
                }
                if (LiuCheng == "项目考察")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.xiangmukaopingchuliren IS NOT NULL";
                }
                if (LiuCheng == "汇总上报")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.reportstate=" + 1 + "";
                }
                if (fenpeizhixingbumen == "请选择")//部门
                {
                }
                else if (fenpeizhixingbumen == "全部")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.fenpeizhixingbumen IS NOT NULL";
                }
                else
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.fenpeizhixingbumen like '%" + fenpeizhixingbumen + "%'";
                }
                if (pingshenxiangmufuzeren == "请选择")//项目组织人
                {
                }
                else if (pingshenxiangmufuzeren == "全部")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.pingshenxiangmufuzeren IS NOT NULL";
                }
                else
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.pingshenxiangmufuzeren like '%" + pingshenxiangmufuzeren + "%'";
                }
                if (AddressCode0 == "请选择")//城市
                {

                }
                else
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.AddressCode1 like '%" + AddressCode0 + "%'";
                    //strPJ += " AND tbs001_developprojectbasicinfo.AddressCode like '%" + AddressCode0 + "%'";
                }
                if (AddressCode1 == "")//地区
                {
                }
                else if (AddressCode1 == "请选择")
                {
                }
                else
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.AddressCode1 like '" + AddressCode0 + "," + AddressCode1 + "'";
                }
                if (pingguyijianxiangmuzhuangtai == "请选择")//项目状态记录
                {
                }
                if (pingguyijianxiangmuzhuangtai == "全部")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.pingguyijianxiangmuzhuangtai = '1736,1737,2288'||tbs001_developprojectbasicinfo.pingguyijianxiangmuzhuangtai = '1737,1736,2288'";
                }
                if (pingguyijianxiangmuzhuangtai == "未批先建")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.pingguyijianxiangmuzhuangtai like '%1736%'";
                }
                if (pingguyijianxiangmuzhuangtai == "重要环境保护目标")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.pingguyijianxiangmuzhuangtai like '%1737%'";
                }
                if (pingguyijianxiangmuzhuangtai == "缺少规划环评")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.pingguyijianxiangmuzhuangtai like '%2288%'";
                }
                if (tuihuiqueren == true)//退回
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.shoulituihuishanchu=" + 2 + "";
                }
                if (lvsetongdao == true)//绿色通道
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.lvsetongdao=" + 1 + "";
                }
                if (queren == true)//复审会议确认
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.queren=" + 1 + "";
                }
                if (hedinghetongjine == "")//核定合同金额
                {
                }
                else
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.hedinghetongjine > " + hedinghetongjine + "";
                }
                if (ReceiveState == "请选择")//是否付款
                {
                }
                else if (ReceiveState == "全部")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.ReceiveState IS NOT NULL";
                }
                else if (ReceiveState == "已付款")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.ReceiveState=" + 1 + "";
                }
                else
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.ReceiveState=" + 0 + "";
                }
                if (ddlxiangmushoulishijian == "请选择")//是否付款
                {
                }
                else if (ddlxiangmushoulishijian == "2010")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.xiangmushoulishijian like '%" + ddlxiangmushoulishijian + "%'";
                }
                else if (ddlxiangmushoulishijian == "2011")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.xiangmushoulishijian like '%" + ddlxiangmushoulishijian + "%'";
                }
                else if (ddlxiangmushoulishijian == "2012")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.xiangmushoulishijian like '%" + ddlxiangmushoulishijian + "%'";
                }
                else if (ddlxiangmushoulishijian == "2013")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.xiangmushoulishijian like '%" + ddlxiangmushoulishijian + "%'";
                }
                else if (ddlxiangmushoulishijian == "2014")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.xiangmushoulishijian like '%" + ddlxiangmushoulishijian + "%'";
                }
                else if (ddlxiangmushoulishijian == "2015")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.xiangmushoulishijian like '%" + ddlxiangmushoulishijian + "%'";
                }
                else if (ddlxiangmushoulishijian == "2016")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.xiangmushoulishijian like '%" + ddlxiangmushoulishijian + "%'";
                }
                else if (ddlxiangmushoulishijian == "2017")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.xiangmushoulishijian like '%" + ddlxiangmushoulishijian + "%'";
                }
                else if (ddlxiangmushoulishijian == "2018")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.xiangmushoulishijian like '%" + ddlxiangmushoulishijian + "%'";
                }
                else if (ddlxiangmushoulishijian == "2019")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.xiangmushoulishijian like '%" + ddlxiangmushoulishijian + "%'";
                }
                if (txtreportdateK != "" && txtreportdatej != "")//汇总上报搜索开始时间，受理搜索结束时间
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.reportdate between '" + txtreportdateK + "' and '" + txtreportdatej + "'";
                }
                if (cbReports == true)//报告书
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.Report='报告书'";
                }
                if (cbReportb == true)//报告表
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.Report='报告表'";
                }
                if (cbNoticeState == true)//审核退回
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.NoticeState=" + 2 + "";
                }
                StringBuilder brb = new StringBuilder();
                brb.AppendFormat("SELECT tbs001_developprojectbasicinfo.*, tbs001_constructionunit.ID,tbs001_constructionunit.NAME AS AClassName, tbs001_evaluationunit.UnitName AS dd FROM tbs001_developprojectbasicinfo,tbs001_constructionunit ,tbs001_evaluationunit WHERE tbs001_developprojectbasicinfo.js=tbs001_constructionunit.ID AND tbs001_developprojectbasicinfo.hp=tbs001_evaluationunit.ID AND tbs001_developprojectbasicinfo.shoulituihuishanchu = 2 AND 1=1 " + strPJ + " ");
                QueryCondition = strPJ;
                return DbHelperMySQL.Query(brb.ToString()).Tables[0];
            }
            catch { return null; }
        }
        #endregion


        #region 搜索条件(按受理搜索开始时间，受理搜索结束时间,行业类别一，行业类别二，行业类别三，环评类别，项目名称，评价单位，流程，部门，项目组织人，城市，地区，项目状态记录,退回,绿色通道,会议复审,核定合同金额)
        public static DataTable GetSelectht(ref string QueryCondition, string XiangMuShouLiShiJianK, string XiangMuShouLiShiJianJ, string IndustryType1, string IndustryType2, string IndustryType3, string huanpingleibie, string ProjectName, string hp, string LiuCheng, string fenpeizhixingbumen, string AddressCode0, string AddressCode1, string hedinghetongjine, string ddlxiangmushoulishijian, string txtreportdateK, string txtreportdatej, bool cbReports, bool cbReportb, bool cbNoticeState, string jinjizhuangtai)
        {
            //，踏查搜索开始时间，踏查搜索结束时间,会议搜索开始时间，会议搜索结束时间
            //string TaChaRiQiK, string TaChaRiQiJ, string HuiYiShiJianK, string HuiYiShiJianJ,string ReceiveState, bool queren, bool lvsetongdao, string pingshenxiangmufuzeren,string pingguyijianxiangmuzhuangtai, , bool tuihuiqueren
            try
            {
                string strPJ = "";
                if (XiangMuShouLiShiJianK != "" && XiangMuShouLiShiJianJ != "")//受理搜索开始时间，受理搜索结束时间(环评)
                {
                    strPJ += " AND a.xiangmushoulishijians between '" + XiangMuShouLiShiJianK + "' and '" + XiangMuShouLiShiJianJ + "'";
                }
                //if (TaChaRiQiK != "" && TaChaRiQiJ != "")//踏查搜索开始时间，踏查搜索结束时间
                //{
                //    strPJ += " AND b.tachariqi between '" + TaChaRiQiK + "' and '" + TaChaRiQiJ + "'";
                //}
                //if (HuiYiShiJianK != "" && HuiYiShiJianJ != "")//会议搜索开始时间，会议搜索结束时间
                //{
                //    strPJ += " AND tbs001_developprojectbasicinfo.huiyishijian between '" + HuiYiShiJianK + "' and '" + HuiYiShiJianJ + "'";
                //}
                //if (HuiYiShiJianK != "" && HuiYiShiJianJ != "")//会议搜索开始时间，会议搜索结束时间
                //{
                //    strPJ += " AND b.zhuanjiahuiyichuliriqi between '" + HuiYiShiJianK + "' and '" + HuiYiShiJianJ + "'";
                //}
                if (jinjizhuangtai == "请选择")//紧急状态
                {
                }

                if (jinjizhuangtai == "普通")
                {
                    strPJ += " AND a.jinjiqingkuang like '" + jinjizhuangtai + "'";
                }
                if (jinjizhuangtai == "急")
                {
                    strPJ += " AND a.jinjiqingkuang like '" + jinjizhuangtai + "'";
                }
                if (jinjizhuangtai == "特急")
                {
                    strPJ += " AND a.jinjiqingkuang like  '" + jinjizhuangtai + "'";
                }

                if (IndustryType1 == "请选择")//行业类别一
                {
                }
                else if (IndustryType1 == "全部")
                {
                    strPJ += " AND b.IndustryType1 IS NOT NULL";
                }
                else
                {
                    strPJ += " AND b.IndustryType1 = '" + IndustryType1 + "'";
                }
                if (IndustryType2 == "")//行业类别二
                {
                }
                else if (IndustryType2 == "请选择")
                {
                }
                else if (IndustryType2 == "全部")
                {
                    strPJ += " AND b.IndustryType2 IS NOT NULL";
                }
                else
                {
                    strPJ += " AND b.IndustryType2 = '" + IndustryType2 + "'";
                }
                if (IndustryType3 == "")//行业类别三
                {
                }
                else if (IndustryType3 == "请选择")
                {
                }
                else if (IndustryType3 == "全部")
                {
                    strPJ += " AND b.IndustryType3 IS NOT NULL";
                }
                else
                {
                    strPJ += " AND b.IndustryType3 = '" + IndustryType3 + "'";
                }
                if (huanpingleibie == "请选择")//环评类别
                {
                }
                else if (huanpingleibie == "全部")//环评类别
                {
                    strPJ += " AND b.huanpingleibie IS NOT NULL";
                }
                else
                {
                    strPJ += " AND b.huanpingleibie like '%" + huanpingleibie + "%'";
                }
                if (ProjectName == "")//项目名称
                {
                }
                else
                {
                    strPJ += " AND b.ProjectName like '%" + ProjectName + "%'";
                }
                if (hp == "请选择")//评价单位
                {
                }
                else if (hp == "全部")//评价单位
                {
                    strPJ += " AND b.hp IS NOT NULL";
                }
                else
                {
                    strPJ += " AND b.hp like '%" + hp + "%'";
                }
                if (LiuCheng == "请选择")//流程(环评)
                {
                }
                if (LiuCheng == "全部")
                {
                    //项目受理，人员分配，起草批复，处长审查，厅长签发
                    strPJ += " AND a.shoulituihui=" + 1 + " and  a.querenfenpei=" + 1 + " and  a.wenjian=" + 1 + " and  a.querenshangchuan=" + 1 + " and  b.qianfa=" + 1 + "";
                }
                if (LiuCheng == "项目受理")
                {
                    strPJ += " AND a.dangqianliucheng like '%" + LiuCheng + "%'";
                }
                if (LiuCheng == "人员分配")
                {
                    strPJ += " AND a.dangqianliucheng like '%" + LiuCheng + "%'";
                }
                if (LiuCheng == "起草批复")
                {
                    strPJ += " AND a.dangqianliucheng like '%" + LiuCheng + "%'";
                }
                if (LiuCheng == "处长审查")
                {
                    strPJ += " AND a.dangqianliucheng like '%" + LiuCheng + "%'";
                }
                if (LiuCheng == "厅长签发")
                {
                    strPJ += " AND a.dangqianliucheng like '%" + LiuCheng + "%'";
                }
                if (fenpeizhixingbumen == "请选择")//经办人
                {
                }
                else if (fenpeizhixingbumen == "全部")
                {
                    strPJ += " AND a.renyuanfeipei IS NOT NULL";
                }
                else
                {
                    strPJ += " AND a.renyuanfeipei like '%" + fenpeizhixingbumen + "%'";
                }
                //if (pingshenxiangmufuzeren == "请选择")//项目组织人
                //{
                //}
                //else if (pingshenxiangmufuzeren == "全部")
                //{
                //    strPJ += " AND b.pingshenxiangmufuzeren IS NOT NULL";
                //}
                //else
                //{
                //    strPJ += " AND b.pingshenxiangmufuzeren like '%" + pingshenxiangmufuzeren + "%'";
                //}
                if (AddressCode0 == "请选择")//城市
                {

                }
                else
                {
                    strPJ += " AND b.AddressCode1 like '%" + AddressCode0 + "%'";
                    //strPJ += " AND tbs001_developprojectbasicinfo.AddressCode like '%" + AddressCode0 + "%'";
                }
                if (AddressCode1 == "")//地区
                {
                }
                else if (AddressCode1 == "请选择")
                {
                }
                else
                {
                    strPJ += " AND b.AddressCode1 like '" + AddressCode0 + "," + AddressCode1 + "'";
                }
                //if (pingguyijianxiangmuzhuangtai == "请选择")//项目状态记录
                //{
                //}
                //if (pingguyijianxiangmuzhuangtai == "全部")
                //{
                //    strPJ += " AND b.pingguyijianxiangmuzhuangtai = '1736,1737,2288'||tbs001_developprojectbasicinfo.pingguyijianxiangmuzhuangtai = '1737,1736,2288'";
                //}
                //if (pingguyijianxiangmuzhuangtai == "未批先建")
                //{
                //    strPJ += " AND b.pingguyijianxiangmuzhuangtai like '%1736%'";
                //}
                //if (pingguyijianxiangmuzhuangtai == "重要环境保护目标")
                //{
                //    strPJ += " AND b.pingguyijianxiangmuzhuangtai like '%1737%'";
                //}
                //if (pingguyijianxiangmuzhuangtai == "缺少规划环评")
                //{
                //    strPJ += " AND b.pingguyijianxiangmuzhuangtai like '%2288%'";
                //}
                //if (tuihuiqueren == true)//受理退回
                //{
                //    strPJ += " AND b.shoulituihuishanchu=" + 2 + "";
                //}
                //if (lvsetongdao == true)//绿色通道
                //{
                //    strPJ += " AND b.lvsetongdao=" + 1 + "";
                //}
                //if (queren == true)//复审会议确认
                //{
                //    strPJ += " AND b.queren=" + 1 + "";
                //}
                if (hedinghetongjine == "")//核定合同金额
                {
                }
                else
                {
                    strPJ += " AND b.hedinghetongjine > " + hedinghetongjine + "";
                }
                //if (ReceiveState == "请选择")//是否付款
                //{
                //}
                //else if (ReceiveState == "全部")
                //{
                //    strPJ += " AND b.ReceiveState IS NOT NULL";
                //}
                //else if (ReceiveState == "已付款")
                //{
                //    strPJ += " AND b.ReceiveState=" + 1 + "";
                //}
                //else
                //{
                //    strPJ += " AND b.ReceiveState=" + 0 + "";
                //}
                if (ddlxiangmushoulishijian == "请选择")//年份
                {
                }
                else if (ddlxiangmushoulishijian == "2010")
                {
                    strPJ += " AND a.xiangmushoulishijians like '%" + ddlxiangmushoulishijian + "%'";
                }
                else if (ddlxiangmushoulishijian == "2011")
                {
                    strPJ += " AND a.xiangmushoulishijians like '%" + ddlxiangmushoulishijian + "%'";
                }
                else if (ddlxiangmushoulishijian == "2012")
                {
                    strPJ += " AND a.xiangmushoulishijians like '%" + ddlxiangmushoulishijian + "%'";
                }
                else if (ddlxiangmushoulishijian == "2013")
                {
                    strPJ += " AND a.xiangmushoulishijians like '%" + ddlxiangmushoulishijian + "%'";
                }
                else if (ddlxiangmushoulishijian == "2014")
                {
                    strPJ += " AND a.xiangmushoulishijians like '%" + ddlxiangmushoulishijian + "%'";
                }
                else if (ddlxiangmushoulishijian == "2015")
                {
                    strPJ += " AND a.xiangmushoulishijians like '%" + ddlxiangmushoulishijian + "%'";
                }
                else if (ddlxiangmushoulishijian == "2016")
                {
                    strPJ += " AND a.xiangmushoulishijians like '%" + ddlxiangmushoulishijian + "%'";
                }
                else if (ddlxiangmushoulishijian == "2017")
                {
                    strPJ += " AND a.xiangmushoulishijians like '%" + ddlxiangmushoulishijian + "%'";
                }
                else if (ddlxiangmushoulishijian == "2018")
                {
                    strPJ += " AND a.xiangmushoulishijians like '%" + ddlxiangmushoulishijian + "%'";
                }
                else if (ddlxiangmushoulishijian == "2019")
                {
                    strPJ += " AND a.xiangmushoulishijians like '%" + ddlxiangmushoulishijian + "%'";
                }
                if (txtreportdateK != "" && txtreportdatej != "")//签发搜索开始时间，签发搜索结束时间
                {
                    strPJ += " AND a.tingzhangqianfashijian between '" + txtreportdateK + "' and '" + txtreportdatej + "'";
                }
                if (cbReports == true)//报告书
                {
                    strPJ += " AND b.Report='报告书'";
                }
                if (cbReportb == true)//报告表
                {
                    strPJ += " AND b.Report='报告表'";
                }
                if (cbNoticeState == true)//审核退回
                {
                    //strPJ += " AND b.NoticeState=" + 2 + "";
                }
                StringBuilder brb = new StringBuilder();

                brb.AppendFormat(@"SELECT a.*,b.*,c.ID,c.NAME AS AClassName,d.UnitName AS dd FROM tbs001_huanping a,tbs001_developprojectbasicinfo b,tbs001_constructionunit c,tbs001_evaluationunit d 
                                 WHERE a.ProjectID = b.ID AND b.js = c.ID AND b.hp = d.ID AND 1=1 " + strPJ + " ");
                QueryCondition = strPJ;
                return DbHelperMySQL.Query(brb.ToString()).Tables[0];
            }
            catch { return null; }
        }
        #endregion


        #region 搜索条件(项目名称,受理日期开始时间,受理日期结束时间,项目负责人,环统类别,环评类别,报告书,报告表,受理退回, 建设性质(新建), 建设性质(改扩建),建设性质(技术改造) )
        public static DataTable GetSelectp(string id, string ProjectName, string XiangMuShouLiShiJianK, string XiangMuShouLiShiJianJ, string xiangmufuzheren, string ESIndustryType, string huanpingleibie, bool Reports, bool Reportb, bool shoulituihuishanchu, bool rbR1, bool rbR2, bool rbR3)
        {
            try
            {
                string strPJ = "";
                if (ProjectName == "")//项目名称
                {
                }
                else
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.ProjectName like '%" + ProjectName + "%'";
                }
                if (XiangMuShouLiShiJianK != "" && XiangMuShouLiShiJianJ != "")//受理搜索开始时间,结束时间
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.xiangmushoulishijian between '" + XiangMuShouLiShiJianK + "' and '" + XiangMuShouLiShiJianJ + "'";
                }
                if (xiangmufuzheren == "请选择")//项目负责人
                {
                }
                else if (xiangmufuzheren == "全部")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.pingshenxiangmufuzeren IS NOT NULL";
                }
                else
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.pingshenxiangmufuzeren ='" + xiangmufuzheren + "'";
                }
                if (ESIndustryType == "请选择")//环统类别
                {
                }
                else if (ESIndustryType == "全部")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.ESIndustryType IS NOT NULL";
                }
                else
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.ESIndustryType = " + ESIndustryType + "";
                }
                if (huanpingleibie == "请选择")//环评类别
                {
                }
                else if (huanpingleibie == "全部")//环评类别
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.huanpingleibie IS NOT NULL";
                }
                else
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.huanpingleibie = " + huanpingleibie + "";
                }
                if (Reports == true)//报告书
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.Report='报告书'";
                }
                if (Reportb == true)//报告表
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.Report='报告表'";
                }
                if (shoulituihuishanchu == true)//审核退回
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.NoticeState=" + 2 + "";
                }
                if (rbR1 == true)//建设性质(新建)
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.DevelopState='新建'";
                }
                if (rbR2 == true)//建设性质(改扩建)
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.DevelopState='改建'";
                }
                if (rbR3 == true)//建设性质(技术改造)
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.DevelopState='扩建'";
                }
                StringBuilder brb = new StringBuilder();
                brb.AppendFormat("SELECT tbs001_developprojectbasicinfo.*,tbs001_constructionunit.ID,tbs001_constructionunit.NAME AS AClassName,tbs001_evaluationunit.UnitName AS dd,tbs001_evaluationunit.ID AS id,tbs001_projectleader.UnitID,tbs001_projectleader.NAME AS pjname FROM tbs001_developprojectbasicinfo,tbs001_constructionunit,tbs001_evaluationunit ,tbs001_projectleader WHERE tbs001_developprojectbasicinfo.js = tbs001_constructionunit.ID  AND tbs001_developprojectbasicinfo.hp = tbs001_evaluationunit.ID AND tbs001_projectleader.UnitID= tbs001_evaluationunit.ID AND tbs001_evaluationunit.ID =" + id + " AND 1 = 1 " + strPJ + " GROUP BY tbs001_developprojectbasicinfo.ProjectName ");
                return DbHelperMySQL.Query(brb.ToString()).Tables[0];
            }
            catch { return null; }
        }
        #endregion

        #region MHSelect
        public static DataTable GetMHSelect(string ProjectName, string DangQianLiuCheng, string hp, string js)
        {
            try
            {
                string strPJ = "";
                if (ProjectName == "")//项目名称
                {
                }
                else
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.ProjectName like '%" + ProjectName + "%'";
                }
                if (DangQianLiuCheng == "请选择")//流程
                {
                }
                if (DangQianLiuCheng == "待审核")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.DangQianLiuCheng='待审核'";
                }
                if (DangQianLiuCheng == "核算金额")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.DangQianLiuCheng='核算金额'";
                }
                if (DangQianLiuCheng == "核定评估金额")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.DangQianLiuCheng='核定评估金额'";
                }
                if (DangQianLiuCheng == "项目受理")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.DangQianLiuCheng='项目受理'";
                }
                if (DangQianLiuCheng == "部门分配")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.DangQianLiuCheng='部门分配'";
                }
                if (DangQianLiuCheng == "项目负责")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.DangQianLiuCheng='项目负责'";
                }
                if (DangQianLiuCheng == "现场踏查")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.DangQianLiuCheng='现场踏查'";
                }
                if (DangQianLiuCheng == "专家会议")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.DangQianLiuCheng='专家会议'";
                }
                if (DangQianLiuCheng == "评估意见")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.DangQianLiuCheng='评估意见'";
                }
                if (DangQianLiuCheng == "项目考察")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.DangQianLiuCheng='项目考察'";
                }
                if (DangQianLiuCheng == "汇总上报")
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.DangQianLiuCheng='汇总上报'";
                }
                if (hp == "请选择")//评价单位
                {
                }
                else
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.hp = '" + hp + "'";
                }
                if (js == "请选择")//建设单位
                {
                }
                else
                {
                    strPJ += " AND tbs001_developprojectbasicinfo.js='" + js + "'";
                }

                StringBuilder brb = new StringBuilder();
                brb.AppendFormat("SELECT tbs001_developprojectbasicinfo.*, tbs001_constructionunit.ID,tbs001_constructionunit.NAME AS AClassName, tbs001_evaluationunit.UnitName AS dd FROM tbs001_developprojectbasicinfo,tbs001_constructionunit ,tbs001_evaluationunit WHERE tbs001_developprojectbasicinfo.js=tbs001_constructionunit.ID AND tbs001_developprojectbasicinfo.hp=tbs001_evaluationunit.ID AND tbs001_developprojectbasicinfo.DangQianLiuCheng IS NOT NULL AND 1=1 " + strPJ + " ");
                return DbHelperMySQL.Query(brb.ToString()).Tables[0];
            }
            catch { return null; }
        }
        #endregion
        #region 地图坐标GetByID
        public static DevelopprojectbasicinfoDataCollection GetByIDs(string IDlist)
        {
            DevelopprojectbasicinfoDataCollection hs = new DevelopprojectbasicinfoDataCollection();
            try
            {
                //                string sql = (@"SELECT a.jingdu,a.weidu,a.ProjectName,a.Investment,d.DataValue,b.ID,b.NAME,c.UnitName,a.ProjectAddress,a.EIAIndustryType 
                //                                        FROM tbs001_developprojectbasicinfo a,tbs001_constructionunit b,tbs001_evaluationunit c,tbs001_basicdatasub d 
                //                                        WHERE a.js = b.id AND a.hp = c.ID AND a.huanpingleibie = d.ID AND a.ID in (" + IDlist + ")");
                string sql = @"SELECT 
                                  a.jingdu,
                                  a.weidu,
                                  a.ProjectName,
                                  a.Investment,
                                  d.DataValue,
                                  b.ID,
                                  b.NAME,
                                  c.UnitName,
                                  a.ProjectAddress,
                                  a.EIAIndustryType 
                                FROM
                                  tbs001_developprojectbasicinfo a LEFT JOIN
                                  tbs001_constructionunit b ON a.js = b.id LEFT JOIN
                                  tbs001_evaluationunit c ON a.hp = c.ID LEFT JOIN
                                  tbs001_basicdatasub d ON a.huanpingleibie = d.ID
                                WHERE a.ID IN (" + IDlist + ")";
                MySqlDataReader dr = DbHelperMySQL.ExecuteReader(sql);
                while (dr.Read())
                {
                    DevelopprojectbasicinfoData model = new DevelopprojectbasicinfoData();
                    JianshehuanjingupModels jj = new JianshehuanjingupModels();
                    if (dr[0] != DBNull.Value)
                        model.jingdu = dr[0].ToString();
                    if (dr[1] != DBNull.Value)
                        model.weidu = dr[1].ToString();
                    if (dr[2] != DBNull.Value)
                        model.ProjectName = dr[2].ToString();
                    if (dr[3] != DBNull.Value)
                        model.Investment = dr[3].ToString();
                    if (dr[4] != DBNull.Value)
                        model.huanpingleibieName = dr[4].ToString();
                    if (dr[5] != DBNull.Value)
                        jj.Id = Convert.ToInt32(dr[5]);
                    if (dr[6] != DBNull.Value)
                        model.AClassName = dr[6].ToString();
                    if (dr[7] != DBNull.Value)
                        model.UnitName = dr[7].ToString();
                    if (dr[8] != DBNull.Value)
                        model.address = dr[8].ToString();
                    if (dr[9] != DBNull.Value)
                        model.EIAIndustryType = dr[9].ToString();
                    hs.Add(model);
                }
                return hs;
            }
            catch
            {
                return null;
            }
        }
        #endregion

        #region MyRegion




        public static DevelopprojectbasicinfoDataCollection GetByIDPdd(string ProjectName)
        {
            DevelopprojectbasicinfoDataCollection hs = new DevelopprojectbasicinfoDataCollection();
            try
            {

                StringBuilder br = new StringBuilder();
                br.AppendFormat(" SELECT ProjectName,ID FROM tbs001_developprojectbasicinfo WHERE tbs001_developprojectbasicinfo.ProjectName = '" + ProjectName + "'");
                MySqlDataReader dr = DbHelperMySQL.ExecuteReader(br.ToString());
                while (dr.Read())
                {
                    DevelopprojectbasicinfoData model = new DevelopprojectbasicinfoData();

                    if (dr[0] != DBNull.Value)
                        model.ProjectName = dr[0].ToString();
                    if (dr[1] != DBNull.Value)
                        model.ID =Convert.ToInt32(dr[1]);
                    hs.Add(model);
                }
                return hs;
            }
            catch
            {
                return null;
            }
        }





        public static DevelopprojectbasicinfoDataCollection GetByIDP(string ProjectName)
        {
            DevelopprojectbasicinfoDataCollection hs = new DevelopprojectbasicinfoDataCollection();
            try
            {

                StringBuilder br = new StringBuilder();
                br.AppendFormat(@"SELECT tbs001_developprojectbasicinfo.ProjectName,tbs001_developprojectbasicinfo.ProjectAddress,tbs001_developprojectbasicinfo.ProjectPerson,tbs001_developprojectbasicinfo.Mobil,tbs001_developprojectbasicinfo.EnvironmentalInvestmentProportion,tbs001_developprojectbasicinfo.Investment,tbs001_developprojectbasicinfo.GPSE,tbs001_developprojectbasicinfo.Report,");
                br.AppendFormat(" tbs001_developprojectbasicinfo.jingdu,tbs001_developprojectbasicinfo.weidu,tbs001_developprojectbasicinfo.pingjiajingfei,tbs001_developprojectbasicinfo.DevelopState,tbs001_constructionunit.NAME AS cname,tbs001_constructionunit.Phone AS cphone,tbs001_constructionunit.ren AS cren,tbs001_constructionunit.Address AS CAddress,tbs001_constructionunit.ZipCode AS CZipCode,");
                br.AppendFormat(" tbs001_constructionunit.lianxiren AS Clianxiren,tbs001_evaluationunit.UnitName AS eUnitName,tbs001_evaluationunit.ZipCode AS EZipCode,tbs001_evaluationunit.Address AS EAddress,tbs001_evaluationunit.CertificateNo AS ECertificateNo,tbs001_developprojectbasicinfo.hplianxiren,tbs001_evaluationunit.Phone AS EPhone,tbs001_developprojectbasicinfo.dianhua,");
                br.AppendFormat(" tbs001_developprojectbasicinfo.xmmsxx,tbs001_developprojectbasicinfo.EIAIndustryType,tbs001_projectleader.NAME AS PName,");
                br.AppendFormat(" (SELECT DataValue FROM tbs001_basicdatasub WHERE tbs001_basicdatasub.MainID=14 AND tbs001_basicdatasub.DataValueMemo = tbs001_developprojectbasicinfo.IndustryType1) AS BIndustryType1,");
                br.AppendFormat(" (SELECT DataValue FROM tbs001_basicdatasub WHERE tbs001_basicdatasub.MainID=24 AND tbs001_basicdatasub.DataValueMemo = tbs001_developprojectbasicinfo.IndustryType2) AS BIndustryType2,");
                br.AppendFormat(" (SELECT DataValue FROM tbs001_basicdatasub WHERE tbs001_basicdatasub.MainID=25 AND tbs001_basicdatasub.DataValueMemo = tbs001_developprojectbasicinfo.IndustryType3) AS BIndustryType3,");
                br.AppendFormat(" (SELECT DataValue FROM tbs001_basicdatasub WHERE tbs001_basicdatasub.MainID=7 AND tbs001_basicdatasub.ID = tbs001_developprojectbasicinfo.huanpingleibie) AS Bhuanpingleibie,");
                br.AppendFormat(" (SELECT DataValue FROM tbs001_basicdatasub WHERE tbs001_basicdatasub.MainID=75 AND tbs001_basicdatasub.ID = tbs001_developprojectbasicinfo.ESIndustryType) AS BESIndustryType,");
                br.AppendFormat(" (SELECT DataValue FROM tbs001_basicdatasub WHERE tbs001_basicdatasub.MainID=30 AND tbs001_basicdatasub.DataValueMemo = SUBSTRING(tbs001_developprojectbasicinfo.AddressCode1, 1,6)) AS chengshi,");
                br.AppendFormat(" (SELECT DataValue FROM tbs001_basicdatasub WHERE tbs001_basicdatasub.MainID=30 AND tbs001_basicdatasub.DataValueMemo = SUBSTRING(tbs001_developprojectbasicinfo.AddressCode1, - 6)) AS diqu ");
                br.AppendFormat(" FROM tbs001_developprojectbasicinfo,tbs001_constructionunit,tbs001_evaluationunit,tbs001_projectleader");
                br.AppendFormat(" WHERE tbs001_developprojectbasicinfo.js = tbs001_constructionunit.ID AND tbs001_developprojectbasicinfo.hp = tbs001_evaluationunit.ID AND tbs001_developprojectbasicinfo.xiangmufuzheren = tbs001_projectleader.ID AND tbs001_developprojectbasicinfo.ProjectName = '" + ProjectName + "'");
                MySqlDataReader dr = DbHelperMySQL.ExecuteReader(br.ToString());
                while (dr.Read())
                {
                    DevelopprojectbasicinfoData model = new DevelopprojectbasicinfoData();
                    //JianshehuanjingupModels jj = new JianshehuanjingupModels();
                    if (dr[0] != DBNull.Value)
                        model.ProjectName = dr[0].ToString();
                    if (dr[1] != DBNull.Value)
                        model.ProjectAddress = dr[1].ToString();
                    if (dr[2] != DBNull.Value)
                        model.ProjectPerson = dr[2].ToString();
                    if (dr[3] != DBNull.Value)
                        model.Mobil = dr[3].ToString();
                    if (dr[4] != DBNull.Value)
                        model.EnvironmentalInvestmentProportion = dr[4].ToString();
                    if (dr[5] != DBNull.Value)
                        model.Investment = dr[5].ToString();
                    if (dr[6] != DBNull.Value)
                        model.GPSE = dr[6].ToString();
                    if (dr[7] != DBNull.Value)
                        model.Report = dr[7].ToString();
                    if (dr[8] != DBNull.Value)
                        model.jingdu = dr[8].ToString();
                    if (dr[9] != DBNull.Value)
                        model.weidu = dr[9].ToString();
                    if (dr[10] != DBNull.Value)
                        model.pingjiajingfei = dr[10].ToString();
                    if (dr[11] != DBNull.Value)
                        model.DevelopState = dr[11].ToString();
                    if (dr[12] != DBNull.Value)
                        model.cname = dr[12].ToString();
                    if (dr[13] != DBNull.Value)
                        model.cphone = dr[13].ToString();
                    if (dr[14] != DBNull.Value)
                        model.Cren = dr[14].ToString();
                    if (dr[15] != DBNull.Value)
                        model.CAddress = dr[15].ToString();
                    if (dr[16] != DBNull.Value)
                        model.CZipCode = dr[16].ToString();
                    if (dr[17] != DBNull.Value)
                        model.Clianxiren = dr[17].ToString();
                    if (dr[18] != DBNull.Value)
                        model.EUnitName = dr[18].ToString();
                    if (dr[19] != DBNull.Value)
                        model.EZipCode = dr[19].ToString();
                    if (dr[20] != DBNull.Value)
                        model.EAddress = dr[20].ToString();
                    if (dr[21] != DBNull.Value)
                        model.ECertificateNo = dr[21].ToString();
                    if (dr[22] != DBNull.Value)
                        model.hplianxiren = dr[22].ToString();
                    if (dr[23] != DBNull.Value)
                        model.EPhone = dr[23].ToString();
                    if (dr[24] != DBNull.Value)
                        model.dianhua = dr[24].ToString();
                    if (dr[25] != DBNull.Value)
                        model.xmmsxx = dr[25].ToString();
                    if (dr[26] != DBNull.Value)
                        model.EIAIndustryType = dr[26].ToString();
                    if (dr[27] != DBNull.Value)
                        model.PName = dr[27].ToString();
                    if (dr[28] != DBNull.Value)
                        model.BIndustryType1 = dr[28].ToString();
                    if (dr[29] != DBNull.Value)
                        model.BIndustryType2 = dr[29].ToString();
                    if (dr[30] != DBNull.Value)
                        model.BIndustryType3 = dr[30].ToString();
                    if (dr[31] != DBNull.Value)
                        model.Bhuanpingleibie = dr[31].ToString();
                    if (dr[32] != DBNull.Value)
                        model.BESIndustryType = dr[32].ToString();
                    if (dr[33] != DBNull.Value)
                        model.Chengshi = dr[33].ToString();
                    if (dr[34] != DBNull.Value)
                        model.Diqu = dr[34].ToString();
                    hs.Add(model);
                }
                return hs;
            }
            catch
            {
                return null;
            }
        }
        #endregion

        #region MyRegion
        public static DevelopprojectbasicinfoDataCollection GetByIDPs(string pj)
        {
            DevelopprojectbasicinfoDataCollection hs = new DevelopprojectbasicinfoDataCollection();
            try
            {
                StringBuilder br = new StringBuilder();
                br.AppendFormat(@"SELECT tbs001_developprojectbasicinfo.ProjectName,tbs001_developprojectbasicinfo.ProjectLog,tbs001_developprojectbasicinfo.nanduxishu,");
                br.AppendFormat(" tbs001_developprojectbasicinfo.hangyexishu,tbs001_developprojectbasicinfo.biaozhunhetongjine,tbs001_developprojectbasicinfo.hedinghetongjine,");
                br.AppendFormat(" tbs001_developprojectbasicinfo.hesuanren,tbs001_developprojectbasicinfo.fenpeizhixingbumen,tbs001_developprojectbasicinfo.tachariqi,");
                br.AppendFormat(" tbs001_developprojectbasicinfo.tachadidian,tbs001_developprojectbasicinfo.tachazhuanjia,tbs001_developprojectbasicinfo.huanpingdanweikaoping,");
                br.AppendFormat(" tbs001_developprojectbasicinfo.chugaokaoping,tbs001_developprojectbasicinfo.huizongshangbaoshumiancailiao,tbs001_developprojectbasicinfo.fushenhuiyipingshenjieguo,");
                br.AppendFormat(" tbs001_developprojectbasicinfo.zhuanjiahuiyididian,tbs001_developprojectbasicinfo.zhuanjiahuiyizhuanjian,tbs001_developprojectbasicinfo.hantacha,");
                br.AppendFormat(" tbs001_developprojectbasicinfo.hanhuiyi,tbs001_developprojectbasicinfo.lvsetongdao,tbs001_developprojectbasicinfo.biangengxiangmu,");
                br.AppendFormat(" tbs001_developprojectbasicinfo.yushenxiangmu,tbs001_developprojectbasicinfo.buhegetiaokuan,tbs001_developprojectbasicinfo.pingguyijianxiangmuzhuangtai,");
                br.AppendFormat(" tbs001_developprojectbasicinfo.huiyipingshenjieguo,tbs001_developprojectbasicinfo.pingguyijianhuiyididian,tbs001_developprojectbasicinfo.pingguyijianhuiyiriqi,");
                br.AppendFormat(" tbs001_developprojectbasicinfo.shangwu,tbs001_developprojectbasicinfo.xiawu,tbs001_developprojectbasicinfo.yijianbeizhu,tbs001_developprojectbasicinfo.buhegeshuoming,");
                br.AppendFormat(" tbs001_developprojectbasicinfo.zhuanjiahuiyichuliriqi,tbs001_developprojectbasicinfo.AppraisalTrace,tbs001_developprojectbasicinfo.OpinionTrace,");
                br.AppendFormat(" tbs001_developprojectbasicinfo.ExpertMeetingTrace,tbs001_developprojectbasicinfo.LookTrace,tbs001_developprojectbasicinfo.ResponTrace,");
                br.AppendFormat(" tbs001_developprojectbasicinfo.DistributionTrace,tbs001_developprojectbasicinfo.yushenxiangmu,tbs001_developprojectbasicinfo.shoulituihuishanchu,");
                br.AppendFormat(" tbs001_developprojectbasicinfo.ReportingTrace,tbs001_developprojectbasicinfo.pingshenxiangmufuzeren,");
                br.AppendFormat(" (SELECT tbs001_basicdatasub.DataValue FROM tbs001_basicdatasub WHERE tbs001_basicdatasub.MainID=32 AND tbs001_developprojectbasicinfo.pingguyijianxiangmuzhuangtai = tbs001_basicdatasub.ID) AS dDataValue,");
                br.AppendFormat(" (SELECT tbs001_basicdatasub.DataValue FROM tbs001_basicdatasub WHERE tbs001_basicdatasub.MainID=29 AND tbs001_developprojectbasicinfo.huizongshangbaoshumiancailiao = tbs001_basicdatasub.ID) AS dhuiDataValue,");
                br.AppendFormat(" (SELECT tbs001_user.Phone FROM tbs001_user WHERE tbs001_developprojectbasicinfo.pingshenxiangmufuzeren = tbs001_user.UserName) AS uphone,");
                br.AppendFormat(" tbs001_developprojectbasicinfo.ProjectMemo,tbs001_developprojectbasicinfo.zhonggaokaoping,tbs001_developprojectbasicinfo.xiangmushouliren,tbs001_developprojectbasicinfo.xiangmushoulishijian,");
                br.AppendFormat(" tbs001_developprojectbasicinfo.zhuanjiahuiyiriqiflag,hdpgjer,");
                br.AppendFormat(" (SELECT tbs001_basicdatasub.DataValue FROM tbs001_basicdatasub WHERE tbs001_basicdatasub.MainID=12 AND tbs001_developprojectbasicinfo.buhegetiaokuan = tbs001_basicdatasub.ID) AS dbuhuiDataValue");
                br.AppendFormat(" FROM tbs001_developprojectbasicinfo");
                br.AppendFormat(" WHERE tbs001_developprojectbasicinfo.ProjectName ='" + pj + "'");
                MySqlDataReader dr = DbHelperMySQL.ExecuteReader(br.ToString());
                while (dr.Read())
                {
                    DevelopprojectbasicinfoData model = new DevelopprojectbasicinfoData();

                    #region model
                    if (dr[0] != DBNull.Value)
                        model.ProjectName = dr[0].ToString();//项目名
                    if (dr[1] != DBNull.Value)
                        model.ProjectLog = dr[1].ToString();//项目日志
                    if (dr[2] != DBNull.Value)
                        model.nanduxishu = dr[2].ToString();//难度系数
                    if (dr[3] != DBNull.Value)
                        model.hangyexishu = dr[3].ToString();//行业系数
                    if (dr[4] != DBNull.Value)
                        model.biaozhunhetongjine = dr[4].ToString();//标准合同金额
                    if (dr[5] != DBNull.Value)
                        model.hedinghetongjine = dr[5].ToString();//核定合同金额
                    if (dr[6] != DBNull.Value)
                        model.hesuanren = dr[6].ToString();//核算人
                    if (dr[7] != DBNull.Value)
                        model.fenpeizhixingbumen = dr[7].ToString();//分配执行部门
                    if (dr[8] != DBNull.Value)
                        model.tachariqi = dr[8].ToString();//踏查日期
                    if (dr[9] != DBNull.Value)
                        model.tachadidian = dr[9].ToString();//踏查地点
                    if (dr[10] != DBNull.Value)
                        model.tachazhuanjia = dr[10].ToString();//踏查专家
                    if (dr[11] != DBNull.Value)
                        model.huanpingdanweikaoping = dr[11].ToString();//环评单位考评
                    if (dr[12] != DBNull.Value)
                        model.chugaokaoping = dr[12].ToString();//初稿考评
                    if (dr[13] != DBNull.Value)
                        model.huizongshangbaoshumiancailiao = dr[13].ToString();//汇总上报书面材料
                    if (dr[14] != DBNull.Value)
                        model.fushenhuiyipingshenjieguo = dr[14].ToString();//复审会议评审结果
                    if (dr[15] != DBNull.Value)
                        model.zhuanjiahuiyididian = dr[15].ToString();//专家会议地点
                    if (dr[16] != DBNull.Value)
                        model.zhuanjiahuiyizhuanjian = dr[16].ToString();//专家会议专家
                    if (dr[17] != DBNull.Value)
                        model.hantacha = Convert.ToInt32(dr[17]);//含踏查
                    if (dr[18] != DBNull.Value)
                        model.hanhuiyi = Convert.ToInt32(dr[18]);//含会议
                    if (dr[19] != DBNull.Value)
                        model.lvsetongdao = Convert.ToInt32(dr[19]);//绿色通道
                    if (dr[20] != DBNull.Value)
                        model.biangengxiangmu = Convert.ToInt32(dr[20]);//变更项目
                    if (dr[21] != DBNull.Value)
                        model.yushenxiangmu = Convert.ToInt32(dr[21]);//预审项目
                    if (dr[22] != DBNull.Value)
                        model.buhegetiaokuan = dr[22].ToString();//不合格条款
                    if (dr[23].ToString() == "1736,1737,2288")
                    {
                        model.pingguyijianxiangmuzhuangtai = "未批先建，重要环境保护目标，缺少规划环评";
                    }
                    else if (dr[23].ToString() == "1736,1737")
                    {
                        model.pingguyijianxiangmuzhuangtai = "未批先建，重要环境保护目标";
                    }
                    else if (dr[23].ToString() == "1736,2288")
                    {
                        model.pingguyijianxiangmuzhuangtai = "未批先建，缺少规划环评";
                    }
                    else if (dr[23].ToString() == "1737,2288")
                    {
                        model.pingguyijianxiangmuzhuangtai = "重要环境保护目标，缺少规划环评";
                    }
                    else if (dr[23].ToString() == "1736")
                    {
                        model.pingguyijianxiangmuzhuangtai = "未批先建";
                    }
                    else if (dr[23].ToString() == "1737")
                    {
                        model.pingguyijianxiangmuzhuangtai = "重要环境保护目标";
                    }
                    else if (dr[23].ToString() == "2288")
                    {
                        model.pingguyijianxiangmuzhuangtai = "缺少规划环评";
                    }
                    //if (dr[23] != DBNull.Value)tbs001_basicdatasub
                    //    model.pingguyijianxiangmuzhuangtai = dr[23].ToString();//评估意见项目状态
                    if (dr[24] != DBNull.Value)
                        model.huiyipingshenjieguo = dr[24].ToString();//会议评审结果
                    if (dr[25] != DBNull.Value)
                        model.pingguyijianhuiyididian = dr[25].ToString();//评估意见会议地点
                    if (dr[26] != DBNull.Value)
                        model.pingguyijianhuiyiriqi = dr[26].ToString();//评估意见会议日期
                    if (dr[27] != DBNull.Value)
                        model.shangwu = Convert.ToInt32(dr[27]);//上午
                    if (dr[28] != DBNull.Value)
                        model.xiawu = Convert.ToInt32(dr[28]);//下午
                    if (dr[29] != DBNull.Value)
                        model.yijianbeizhu = dr[29].ToString();//意见备注
                    if (dr[30] != DBNull.Value)
                        model.buhegeshuoming = dr[30].ToString();//不合格说明
                    if (dr[31] != DBNull.Value)
                        model.zhuanjiahuiyichuliriqi = dr[31].ToString();//专家会议处理日期
                    if (dr[32] != DBNull.Value)
                        model.AppraisalTrace = dr[32].ToString();//项目考评操作痕迹
                    if (dr[33] != DBNull.Value)
                        model.OpinionTrace = dr[33].ToString();//评估意见操作痕迹
                    if (dr[34] != DBNull.Value)
                        model.ExpertMeetingTrace = dr[34].ToString();//专家会议操作痕迹
                    if (dr[35] != DBNull.Value)
                        model.LookTrace = dr[35].ToString();//现场踏查操作痕迹
                    if (dr[36] != DBNull.Value)
                        model.ResponTrace = dr[36].ToString();//项目负责操作痕迹
                    if (dr[37] != DBNull.Value)
                        model.DistributionTrace = dr[37].ToString();//部门分配操作痕迹
                    if (dr[38] != DBNull.Value)
                        model.yushenxiangmu = Convert.ToInt32(dr[38]);//预审项目
                    if (dr[39] != DBNull.Value)
                        model.shoulituihuishanchu = Convert.ToInt32(dr[39]);//受理退回删除
                    if (dr[40] != DBNull.Value)
                        model.ReportingTrace = dr[40].ToString();//汇总上报操作痕迹
                    if (dr[41] != DBNull.Value)
                        model.pingshenxiangmufuzeren = dr[41].ToString();//评审项目负责人
                    if (dr[42] != DBNull.Value)
                        model.dDataValue = dr[42].ToString();//项目状态
                    if (dr[43] != DBNull.Value)
                        model.dhuiDataValue = dr[43].ToString();//汇总上报书面材料
                    if (dr[44] != DBNull.Value)
                        model.uphone = dr[44].ToString();
                    if (dr[45] != DBNull.Value)
                        model.ProjectMemo = dr[45].ToString();//项目注释
                    if (dr[46] != DBNull.Value)
                        model.zhonggaokaoping = dr[46].ToString();
                    if (dr[47] != DBNull.Value)
                        model.xiangmushouliren = dr[47].ToString();
                    if (dr[48] != DBNull.Value)
                        model.xiangmushoulishijian = dr[48].ToString();
                    if (dr[49] != DBNull.Value)
                        model.zhuanjiahuiyiriqiflag = Convert.ToInt32(dr[49]);
                    if (dr[50] != DBNull.Value)
                        model.Hdpgjer = dr[50].ToString();
                    if (dr[51] != DBNull.Value)
                        model.dbuhuiDataValue = dr[51].ToString();
                    #endregion
                    hs.Add(model);
                }
                return hs;
            }
            catch
            {
                return null;
            }
        }
        #endregion

        #region 搜索条件按(项目名称,类别,紧急状况,经办人,流程,评价单位)(项目跟踪)(x)
        public static DataTable GetSelectgz(string txtProjectName, string ddlhuanpingleibie, string ddljinjizhuangtai, string ddlLiuCheng, string ddlhp)
        {
            try
            {
                string strPJ = "";
                if (txtProjectName == "")//项目名称
                {
                }
                else
                {
                    strPJ += " AND a.ProjectName like '%" + txtProjectName + "%'";
                }
                if (ddlhuanpingleibie == "请选择")//环评类别
                {
                }
                else if (ddlhuanpingleibie == "全部")
                {
                    strPJ += " AND b.huanpingleibie IS NOT NULL";
                }
                else
                {
                    strPJ += " AND b.huanpingleibie like '%" + ddlhuanpingleibie + "%'";
                }
                if (ddljinjizhuangtai == "请选择")//紧急状态
                {
                }
                if (ddljinjizhuangtai == "普通")
                {
                    strPJ += " AND a.jinjiqingkuang like '" + ddljinjizhuangtai + "'";
                }
                if (ddljinjizhuangtai == "急")
                {
                    strPJ += " AND a.jinjiqingkuang like '" + ddljinjizhuangtai + "'";
                }
                if (ddljinjizhuangtai == "特急")
                {
                    strPJ += " AND a.jinjiqingkuang like  '" + ddljinjizhuangtai + "'";
                }
                if (ddlLiuCheng == "请选择")//流程(环评)
                {
                }
                if (ddlLiuCheng == "全部")
                {
                    //项目受理，人员分配，起草批复，处长审查，厅长签发
                    strPJ += " AND a.shoulituihui=" + 1 + " and  a.querenfenpei=" + 1 + " and  a.wenjian=" + 1 + " and  a.querenshangchuan=" + 1 + " and  b.qianfa=" + 1 + "";
                }
                if (ddlLiuCheng == "项目受理")
                {
                    strPJ += " AND a.dangqianliucheng like '%" + ddlLiuCheng + "%'";
                }
                if (ddlLiuCheng == "人员分配")
                {
                    strPJ += " AND a.dangqianliucheng like '%" + ddlLiuCheng + "%'";
                }
                if (ddlLiuCheng == "起草批复")
                {
                    strPJ += " AND a.dangqianliucheng like '%" + ddlLiuCheng + "%'";
                }
                if (ddlLiuCheng == "处长审查")
                {
                    strPJ += " AND a.dangqianliucheng like '%" + ddlLiuCheng + "%'";
                }
                if (ddlLiuCheng == "厅长签发")
                {
                    strPJ += " AND a.dangqianliucheng like '%" + ddlLiuCheng + "%'";
                }
                if (ddlhp == "请选择")//评价单位
                {
                }
                else if (ddlhp == "全部")
                {
                    strPJ += " AND b.hp IS NOT NULL";
                }
                else
                {
                    strPJ += " AND b.hp like '%" + ddlhp + "%'";
                }
                StringBuilder brb = new StringBuilder();
                brb.AppendFormat(@"SELECT a.*,b.*,c.ID,c.NAME AS AClassName,d.UnitName AS dd,e.DataValue AS hplb FROM tbs001_huanping a,
                                 tbs001_developprojectbasicinfo b,tbs001_constructionunit c,tbs001_evaluationunit d,tbs001_basicdatasub e 
                                 WHERE a.ProjectID = b.ID AND b.js = c.ID AND b.hp = d.ID AND b.huanpingleibie = e.ID AND a.shoulituihui = 1 
                                 AND qianfaTrace ='' AND 1=1 " + strPJ + " ");
                return DbHelperMySQL.Query(brb.ToString()).Tables[0];
            }
            catch { return null; }
        }
        #endregion

        #region 方法GetSelectAllTbs001_developprojectbasicinfo
        public static DataTable GetSelectAllTbs001_developprojectbasicinfo()
        {
            try
            {
                StringBuilder brb = new StringBuilder();
                brb.AppendFormat("SELECT tbs001_developprojectbasicinfo.*, tbs001_constructionunit.ID, tbs001_constructionunit.NAME AS AClassName, tbs001_evaluationunit.UnitName AS dd FROM tbs001_developprojectbasicinfo,tbs001_constructionunit,tbs001_evaluationunit WHERE tbs001_developprojectbasicinfo.js = tbs001_constructionunit.ID AND tbs001_developprojectbasicinfo.hp = tbs001_evaluationunit.ID AND tbs001_developprojectbasicinfo.DangQianLiuCheng IS NOT NULL");
                //brb.AppendFormat("SELECT * from tbs001_developprojectbasicinfo");
                return DbHelperMySQL.Query(brb.ToString()).Tables[0];
            }
            catch { return null; }
        }
        #endregion
    }
}